package top.lyjwn.todo.common.utils;

import com.alibaba.fastjson2.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 生成签名
 *
 * @author luoyujie
 */
public class WXSignUtil extends SignUtil {

    private static final Logger log = LoggerFactory.getLogger(WXSignUtil.class);

    /**
     * 验证签名
     *
     * @param api_key
     * @param object
     * @param sign
     * @return
     */
    public static boolean verify(String api_key, Object object, String sign) {
        boolean verify = SignUtil.verify(api_key, object, sign);
        if (!verify) {
            log.error("   sign====" + sign + "\n mysign====" + getSha256Sign(api_key, object) + "\n " + JSONObject.toJSONString(object));
        }
        return verify;
    }


    /**
     * 验证签名
     *
     * @param api_key
     * @param xml
     * @param sign
     * @return
     */
    public static boolean verify(String api_key, String xml, String sign) {
        return SignUtil.verify(api_key, xml, sign, "sign");
    }

}
